package com.hqj.consumer.controller;

import com.hqj.consumer.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.client.RestTemplate;

@Controller
@RequestMapping("/tc")
public class TestController {
    @Autowired
    private RestTemplate template;

    @Autowired
    private TestService ts;

    @RequestMapping("/t1")
    @ResponseBody
    public String test1(){
        //使用服务提供者提供的服务，即从服务提供者那里获取字符串
        String url = "http://eureka-client-8001:8001/tc/t1?name=123";
        String str = template.getForObject(url,String.class);
        return str;
    }

    @RequestMapping("/t2")
    @ResponseBody
    public String test2(){
        String str = ts.getString("红旗街");
        return str;
    }
}
